<?php
/*
	Aurus CMS - free OOP CMS
	Copyright (C) 2010  Nestor Yanchuk

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 2 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
if (!defined('ROOT')) die();

if (isset($_GET['manage'])) {

	$index = $_GET['manage'];
	$table = Html::tr(
	Html::td(__('Назва'), 'chead', 'left', '34%') . 
	Html::td(__('Статус'), 'chead', 'left', '33%') . 
	Html::td(__('Дія'), 'chead', 'left', '33%')
	);
	for ($i = 0, $n = count($ains[$index]); $i < $n; $i++) {
		$addn = $ains[$index][$i];
		$addn = $addn;
		$table .= Html::tr(
		Html::td($addn, 'confclass', 'left', '34%') . 
		Html::td(Html::tag(__('Додаток увімкнений'), 'span',array('style' => 'color:green')), 'confclass', 'left', '33%') . 
		Html::td(Html::tag(__('Вимкнути'), 'a', array('href' =>	LINK_ROOT . 'adminarea/?do=mods&amp;deactivate=' . $index . '&amp;name=' . $addn)), 'confclass', 'left', '33%'));
	}

	for ($i = 0, $n = count($aunins[$index]); $i < $n; $i++) {
		$addn = $aunins[$index][$i];
		$addn = ($index == 'plugins') ? substr($addn, 0, -4) : $addn;
		$table .= Html::tr(Html::td($addn, 'confclass', 'left', '34%') . Html::td(Html::tag(__('Додаток вимкнений'), 'span',
			array('style' => 'color:red')), 'confclass', 'left', '33%') . Html::td(Html::tag(__('Увімкнути'), 'a', array('href' =>
			LINK_ROOT . 'adminarea/?do=mods&amp;activate=' . $index . '&amp;name=' . $addn)), 'confclass', 'left', '33%'));
	}
	Aurus::getInstance()->addContent(Html::table($table));
} elseif (isset($_GET['activate'])) {
	$type = substr($_GET['activate'], 0, -1);
	Mysql::getInstance()->insert('modules', array('type' => $type, 'name' => $_GET['name']));

	Aurus::getInstance()->addContent(Adminarea::getInstance()->adminInfo(__('Додаток увімкнено')));
	Cache::clear();
} elseif (isset($_GET['deactivate'])) {
	$type = substr($_GET['deactivate'], 0, -1);
	Mysql::getInstance()->delete('modules', "type='{$type}' AND name='{$_GET['name']}'");
	Aurus::getInstance()->addContent(Adminarea::getInstance()->adminInfo(__('Додаток вимкнено')));
	Cache::clear();
}